/*@abstract manages sound
 * Sound: Preseted by http://maoudamashii.jokersounds.com
 */

function SoundFactory(){
	/* constructor */
	if(arguments.callee._singletonInstance ){ 
		return arguments.callee._singletonInstance;	
	}else{
		arguments.callee._singletonInstance = this;

		this.soundPaths = {
			'opening':'./sound/battle.ogg', 
			'battle':'./sound/battle.ogg', 
			'ending':'./sound/ending.ogg',
			'bomb':'./sound/bomb.ogg',
			'atack':'./sound/atack.ogg',
		};
		this.audios = new Array();
		for(var key in this.soundPaths){
			var audio = new Audio("");
			audio.src = this.soundPaths[key];
			audio.load();
			this.audios[key] = audio;
		}
	}	
	/* public methods */
	this.play = function(key, isloop){
		if(typeof isloop === 'undefined') 
			isloop = false;
		this.audios[key].loop = isloop;
		this.audios[key].play();
	}
}

/*public static var */

/* public static method */
SoundFactory.getInstance = function(){
	var singletonClass = new SoundFactory();
	return singletonClass;
}


